/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package info.touret.winecellar.test;

import info.touret.winecellar.bottle.server.domain.Bottle;
import info.touret.winecellar.bottle.server.domain.Tag;
import info.touret.winecellar.bottle.server.domain.Tasting;
import info.touret.winecellar.dao.server.MockDataStoreObject;
import info.touret.winecellar.producer.server.domain.Producer;
import info.touret.winecellar.userinfo.server.domain.UserInfo;

import org.junit.Before;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.googlecode.objectify.ObjectifyService;

/**
 * 
 * @author touret-a
 */
public class GuiceJunit {

	static {
		try {
			registerObjectifyPojos();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@Before
	public void setUp() throws Exception {
		MockDataStoreObject.clearmodules();
		Injector injector = Guice.createInjector(new JunitModule());
		injector.injectMembers(this);
	}

	public static void registerObjectifyPojos() throws Exception {
		ObjectifyService.register(Tag.class);
		ObjectifyService.register(Bottle.class);
		ObjectifyService.register(UserInfo.class);
		ObjectifyService.register(Producer.class);
		ObjectifyService.register(Tasting.class);
	}
}
